#pragma semicolon 1
#include <sourcemod>
#include <sdktools>


public Plugin myinfo =  
{
	name = "l4d2_SurvivorSpeed",  //这里写插件名字
	author = "蛋疼哥,sorallll",   //作者
	description = "",             //介绍
	version = "1.0",              //版本
	url = ""                      //网站
}

public OnPluginStart()
{
   //RegConsoleCmd("move", suduMenu, "开启速度菜单");  //所有人都可以用。
	RegAdminCmd("sm_move", suduMenu, ADMFLAG_BAN);  //开启速度菜单，管理员专用。
}

public Action:suduMenu(client, args)
{
	PlayerSpeedMenu(client);
	return Plugin_Handled;
}

public SpeedMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
	if (action == MenuAction_Select)
	{
		switch (itemNum)
		{
			case 0: 
			{
				SpeedMenu1(client);
			}
			case 1: 
			{
				SpeedMenu2(client);
			}
			case 2: 
			{
				SpeedMenu3(client);
			}
			case 3: 
			{
				SpeedMenu4(client);
			}
			case 4: 
			{
				SpeedMenu5(client);
			}
			case 5: 
			{
				SpeedMenu6(client);
			}
			case 6: 
			{
				SpeedMenu7(client);
			}
			case 7: 
			{
				SpeedMenu8(client);
			}
			case 8: 
			{
				SpeedMenu9(client);
			}
			default: {
			}
		}
	}
}

public Action:PlayerSpeedMenu(clientId)
{
	new Handle:menu = CreateMenu(SpeedMenuHandler);
	SetMenuTitle(menu, "速度菜单");
	AddMenuItem(menu, "option1", "速度1");
	AddMenuItem(menu, "option2", "速度2");
	AddMenuItem(menu, "option3", "默认速度");
	AddMenuItem(menu, "option4", "速度4");
	AddMenuItem(menu, "option5", "速度5");
	AddMenuItem(menu, "option6", "速度6");
	AddMenuItem(menu, "option7", "速度7");
	AddMenuItem(menu, "option8", "速度8");
	AddMenuItem(menu, "option9", "速度9");
	SetMenuExitButton(menu, true);
	DisplayMenu(menu, clientId, MENU_TIME_FOREVER);
	return Plugin_Handled;
}

public SpeedMenu1(client)
{
	new Handle:menu = CreateMenu(Speed1MenuHandler);
	SetMenuTitle(menu, "速度1");
	AddMenuItem(menu, "Speed1", "0.1速度");
	SetMenuExitButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public Speed1MenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
	if (action == MenuAction_Select)
	{
		decl String:clientinfos[12];
		GetMenuItem(menu, itemNum, clientinfos, sizeof(clientinfos));
		DisplaySpeed1Menu(client);
	}
}

public DisplaySpeed1Menu(client)
{
	decl String:name[MAX_NAME_LENGTH];
	decl String:uid[16];
	new Handle:menu = CreateMenu(DisSpeed1MenuHandler);
	SetMenuTitle(menu, "玩家列表");
	AddMenuItem(menu, "allplayer", "<所有人>");
	for(new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
		{
			FormatEx(name, sizeof(name), "%N", i);
			FormatEx(uid, sizeof(uid), "%d", GetClientUserId(i));
			AddMenuItem(menu, uid, name);
		}
	}
	SetMenuExitBackButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public DisSpeed1MenuHandler(Handle:menu, MenuAction:action, Client, itemNum)
{
	switch(action)
	{
		case MenuAction_End:
		{
			delete menu;
		}
		case MenuAction_Select:
		{
			decl String:info[16];
			GetMenuItem(menu, itemNum, info, sizeof(info));
			if(!strcmp(info, "allplayer", true))
			{
				for(new i = 1; i <= MaxClients; i++)
				{
					if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
					{
						SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 0.1);
					}
				}
			}
			else
			{
				SetEntPropFloat(Client, Prop_Data, "m_flLaggedMovementValue", 0.1);
			}
		}
	}
}

public SpeedMenu2(client)
{
	new Handle:menu = CreateMenu(Speed2MenuHandler);
	SetMenuTitle(menu, "速度2");
	AddMenuItem(menu, "Speed2", "0.5速度");
	SetMenuExitButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public Speed2MenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
	if (action == MenuAction_Select)
	{
		decl String:clientinfos[12];
		GetMenuItem(menu, itemNum, clientinfos, sizeof(clientinfos));
		DisplaySpeed2Menu(client);
	}
}

public DisplaySpeed2Menu(client)
{
	decl String:name[MAX_NAME_LENGTH];
	decl String:uid[16];
	new Handle:menu = CreateMenu(DisSpeed2MenuHandler);
	SetMenuTitle(menu, "玩家列表");
	AddMenuItem(menu, "allplayer", "<所有人>");
	for(new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
		{
			FormatEx(name, sizeof(name), "%N", i);
			FormatEx(uid, sizeof(uid), "%d", GetClientUserId(i));
			AddMenuItem(menu, uid, name);
		}
	}
	SetMenuExitBackButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public DisSpeed2MenuHandler(Handle:menu, MenuAction:action, Client, itemNum)
{
	switch(action)
	{
		case MenuAction_End:
		{
			delete menu;
		}
		case MenuAction_Select:
		{
			decl String:info[16];
			GetMenuItem(menu, itemNum, info, sizeof(info));
			if(!strcmp(info, "allplayer", true))
			{
				for(new i = 1; i <= MaxClients; i++)
				{
					if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
					{
						SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 0.5);
					}
				}
			}
			else
			{
				SetEntPropFloat(Client, Prop_Data, "m_flLaggedMovementValue", 0.5);
			}
		}
	}
}

public SpeedMenu3(client)
{
	new Handle:menu = CreateMenu(Speed3MenuHandler);
	SetMenuTitle(menu, "恢复默认速度");
	AddMenuItem(menu, "Speed3", "默认1.1速度");
	SetMenuExitButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public Speed3MenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
	if (action == MenuAction_Select)
	{
		decl String:clientinfos[12];
		GetMenuItem(menu, itemNum, clientinfos, sizeof(clientinfos));
		DisplaySpeed3Menu(client);
	}
}

public DisplaySpeed3Menu(client)
{
	decl String:name[MAX_NAME_LENGTH];
	decl String:uid[16];
	new Handle:menu = CreateMenu(DisSpeed3MenuHandler);
	SetMenuTitle(menu, "玩家列表");
	AddMenuItem(menu, "allplayer", "<所有人>");
	for(new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
		{
			FormatEx(name, sizeof(name), "%N", i);
			FormatEx(uid, sizeof(uid), "%d", GetClientUserId(i));
			AddMenuItem(menu, uid, name);
		}
	}
	SetMenuExitBackButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public DisSpeed3MenuHandler(Handle:menu, MenuAction:action, Client, itemNum)
{
	switch(action)
	{
		case MenuAction_End:
		{
			delete menu;
		}
		case MenuAction_Select:
		{
			decl String:info[16];
			GetMenuItem(menu, itemNum, info, sizeof(info));
			if(!strcmp(info, "allplayer", true))
			{
				for(new i = 1; i <= MaxClients; i++)
				{
					if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
					{
						SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 1.1);
					}
				}
			}
			else
			{
				SetEntPropFloat(Client, Prop_Data, "m_flLaggedMovementValue", 1.1);
			}
		}
	}
}

public SpeedMenu4(client)
{
	new Handle:menu = CreateMenu(Speed4MenuHandler);
	SetMenuTitle(menu, "速度4");
	AddMenuItem(menu, "Speed4", "2.0速度");
	SetMenuExitButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public Speed4MenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
	if (action == MenuAction_Select)
	{
		decl String:clientinfos[12];
		GetMenuItem(menu, itemNum, clientinfos, sizeof(clientinfos));
		DisplaySpeed4Menu(client);
	}
}

public DisplaySpeed4Menu(client)
{
	decl String:name[MAX_NAME_LENGTH];
	decl String:uid[16];
	new Handle:menu = CreateMenu(DisSpeed4MenuHandler);
	SetMenuTitle(menu, "玩家列表");
	AddMenuItem(menu, "allplayer", "<所有人>");
	for(new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
		{
			FormatEx(name, sizeof(name), "%N", i);
			FormatEx(uid, sizeof(uid), "%d", GetClientUserId(i));
			AddMenuItem(menu, uid, name);
		}
	}
	SetMenuExitBackButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public DisSpeed4MenuHandler(Handle:menu, MenuAction:action, Client, itemNum)
{
	switch(action)
	{
		case MenuAction_End:
		{
			delete menu;
		}
		case MenuAction_Select:
		{
			decl String:info[16];
			GetMenuItem(menu, itemNum, info, sizeof(info));
			if(!strcmp(info, "allplayer", true))
			{
				for(new i = 1; i <= MaxClients; i++)
				{
					if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
					{
						SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 2.0);
					}
				}
			}
			else
			{
				SetEntPropFloat(Client, Prop_Data, "m_flLaggedMovementValue", 2.0);
			}
		}
	}
}

public SpeedMenu5(client)
{
	new Handle:menu = CreateMenu(Speed5MenuHandler);
	SetMenuTitle(menu, "速度5");
	AddMenuItem(menu, "Speed5", "3.0速度");
	SetMenuExitButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public Speed5MenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
	if (action == MenuAction_Select)
	{
		decl String:clientinfos[12];
		GetMenuItem(menu, itemNum, clientinfos, sizeof(clientinfos));
		DisplaySpeed5Menu(client);
	}
}

public DisplaySpeed5Menu(client)
{
	decl String:name[MAX_NAME_LENGTH];
	decl String:uid[16];
	new Handle:menu = CreateMenu(DisSpeed5MenuHandler);
	SetMenuTitle(menu, "玩家列表");
	AddMenuItem(menu, "allplayer", "<所有人>");
	for(new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
		{
			FormatEx(name, sizeof(name), "%N", i);
			FormatEx(uid, sizeof(uid), "%d", GetClientUserId(i));
			AddMenuItem(menu, uid, name);
		}
	}
	SetMenuExitBackButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public DisSpeed5MenuHandler(Handle:menu, MenuAction:action, Client, itemNum)
{
	switch(action)
	{
		case MenuAction_End:
		{
			delete menu;
		}
		case MenuAction_Select:
		{
			decl String:info[16];
			GetMenuItem(menu, itemNum, info, sizeof(info));
			if(!strcmp(info, "allplayer", true))
			{
				for(new i = 1; i <= MaxClients; i++)
				{
					if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
					{
						SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 3.0);
					}
				}
			}
			else
			{
				SetEntPropFloat(Client, Prop_Data, "m_flLaggedMovementValue", 3.0);
			}
		}
	}
}

public SpeedMenu6(client)
{
	new Handle:menu = CreateMenu(Speed6MenuHandler);
	SetMenuTitle(menu, "速度6");
	AddMenuItem(menu, "Speed6", "4.0速度");
	SetMenuExitButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public Speed6MenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
	if (action == MenuAction_Select)
	{
		decl String:clientinfos[12];
		GetMenuItem(menu, itemNum, clientinfos, sizeof(clientinfos));
		DisplaySpeed6Menu(client);
	}
}

public DisplaySpeed6Menu(client)
{
	decl String:name[MAX_NAME_LENGTH];
	decl String:uid[16];
	new Handle:menu = CreateMenu(DisSpeed6MenuHandler);
	SetMenuTitle(menu, "玩家列表");
	AddMenuItem(menu, "allplayer", "<所有人>");
	for(new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
		{
			FormatEx(name, sizeof(name), "%N", i);
			FormatEx(uid, sizeof(uid), "%d", GetClientUserId(i));
			AddMenuItem(menu, uid, name);
		}
	}
	SetMenuExitBackButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public DisSpeed6MenuHandler(Handle:menu, MenuAction:action, Client, itemNum)
{
	switch(action)
	{
		case MenuAction_End:
		{
			delete menu;
		}
		case MenuAction_Select:
		{
			decl String:info[16];
			GetMenuItem(menu, itemNum, info, sizeof(info));
			if(!strcmp(info, "allplayer", true))
			{
				for(new i = 1; i <= MaxClients; i++)
				{
					if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
					{
						SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 4.0);
					}
				}
			}
			else
			{
				SetEntPropFloat(Client, Prop_Data, "m_flLaggedMovementValue", 4.0);
			}
		}
	}
}

public SpeedMenu7(client)
{
	new Handle:menu = CreateMenu(Speed7MenuHandler);
	SetMenuTitle(menu, "速度7");
	AddMenuItem(menu, "Speed7", "5.0速度");
	SetMenuExitButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public Speed7MenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
	if (action == MenuAction_Select)
	{
		decl String:clientinfos[12];
		GetMenuItem(menu, itemNum, clientinfos, sizeof(clientinfos));
		DisplaySpeed7Menu(client);
	}
}

public DisplaySpeed7Menu(client)
{
	decl String:name[MAX_NAME_LENGTH];
	decl String:uid[16];
	new Handle:menu = CreateMenu(DisSpeed7MenuHandler);
	SetMenuTitle(menu, "玩家列表");
	AddMenuItem(menu, "allplayer", "<所有人>");
	for(new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
		{
			FormatEx(name, sizeof(name), "%N", i);
			FormatEx(uid, sizeof(uid), "%d", GetClientUserId(i));
			AddMenuItem(menu, uid, name);
		}
	}
	SetMenuExitBackButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public DisSpeed7MenuHandler(Handle:menu, MenuAction:action, Client, itemNum)
{
	switch(action)
	{
		case MenuAction_End:
		{
			delete menu;
		}
		case MenuAction_Select:
		{
			decl String:info[16];
			GetMenuItem(menu, itemNum, info, sizeof(info));
			if(!strcmp(info, "allplayer", true))
			{
				for(new i = 1; i <= MaxClients; i++)
				{
					if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
					{
						SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 5.0);
					}
				}
			}
			else
			{
				SetEntPropFloat(Client, Prop_Data, "m_flLaggedMovementValue", 5.0);
			}
		}
	}
}

public SpeedMenu8(client)
{
	new Handle:menu = CreateMenu(Speed8MenuHandler);
	SetMenuTitle(menu, "速度8");
	AddMenuItem(menu, "Speed8", "10.0速度");
	SetMenuExitButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public Speed8MenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
	if (action == MenuAction_Select)
	{
		decl String:clientinfos[12];
		GetMenuItem(menu, itemNum, clientinfos, sizeof(clientinfos));
		DisplaySpeed8Menu(client);
	}
}

public DisplaySpeed8Menu(client)
{
	decl String:name[MAX_NAME_LENGTH];
	decl String:uid[16];
	new Handle:menu = CreateMenu(DisSpeed8MenuHandler);
	SetMenuTitle(menu, "玩家列表");
	AddMenuItem(menu, "allplayer", "<所有人>");
	for(new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
		{
			FormatEx(name, sizeof(name), "%N", i);
			FormatEx(uid, sizeof(uid), "%d", GetClientUserId(i));
			AddMenuItem(menu, uid, name);
		}
	}
	SetMenuExitBackButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public DisSpeed8MenuHandler(Handle:menu, MenuAction:action, Client, itemNum)
{
	switch(action)
	{
		case MenuAction_End:
		{
			delete menu;
		}
		case MenuAction_Select:
		{
			decl String:info[16];
			GetMenuItem(menu, itemNum, info, sizeof(info));
			if(!strcmp(info, "allplayer", true))
			{
				for(new i = 1; i <= MaxClients; i++)
				{
					if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
					{
						SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 10.0);
					}
				}
			}
			else
			{
				SetEntPropFloat(Client, Prop_Data, "m_flLaggedMovementValue", 10.0);
			}
		}
	}
}

public SpeedMenu9(client)
{
	new Handle:menu = CreateMenu(Speed9MenuHandler);
	SetMenuTitle(menu, "速度9");
	AddMenuItem(menu, "Speed9", "15.0速度");
	SetMenuExitButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public Speed9MenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
	if (action == MenuAction_Select)
	{
		decl String:clientinfos[12];
		GetMenuItem(menu, itemNum, clientinfos, sizeof(clientinfos));
		DisplaySpeed9Menu(client);
	}
}

public DisplaySpeed9Menu(client)
{
	decl String:name[MAX_NAME_LENGTH];
	decl String:uid[16];
	new Handle:menu = CreateMenu(DisSpeed9MenuHandler);
	SetMenuTitle(menu, "玩家列表");
	AddMenuItem(menu, "allplayer", "<所有人>");
	for(new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
		{
			FormatEx(name, sizeof(name), "%N", i);
			FormatEx(uid, sizeof(uid), "%d", GetClientUserId(i));
			AddMenuItem(menu, uid, name);
		}
	}
	SetMenuExitBackButton(menu, true);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}

public DisSpeed9MenuHandler(Handle:menu, MenuAction:action, Client, itemNum)
{
	switch(action)
	{
		case MenuAction_End:
		{
			delete menu;
		}
		case MenuAction_Select:
		{
			decl String:info[16];
			GetMenuItem(menu, itemNum, info, sizeof(info));
			if(!strcmp(info, "allplayer", true))
			{
				for(new i = 1; i <= MaxClients; i++)
				{
					if(IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
					{
						SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 15.0);
					}
				}
			}
			else
			{
				SetEntPropFloat(Client, Prop_Data, "m_flLaggedMovementValue", 15.0);
			}
		}
	}
}